package org.wangblue.concrete_mediator;

import org.wangblue.colleague.Colleague;
import org.wangblue.concrete_colleague.ConcreteColleague1;
import org.wangblue.concrete_colleague.ConcreteColleague2;
import org.wangblue.mediator.Mediator;

/**
 * @Description: 抽象中介者的实现类
 * @Author: WangBlue
 * @Create: 2024-09-25 10:22
 * @Version: 1.0
 **/

public class ConcreteMediator extends Mediator {
    private ConcreteColleague1 colleague1;
    private ConcreteColleague2 colleague2;

    public void setColleague1(ConcreteColleague1 colleague1) {
        this.colleague1 = colleague1;
    }
    public void setColleague2(ConcreteColleague2 colleague2) {
        this.colleague2 = colleague2;
    }

    @Override
    public void send(String message, Colleague colleague) {
        if (colleague == colleague1) {
            colleague1.nodtify(message);
        }else {
            colleague2.nodtify(message);
        }
    }
}
